<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "comments_relation".
 *
 * @property integer $id
 * @property integer $comment_id
 * @property integer $order_id
 * @property integer $goods_id
 * @property integer $product_id
 * @property integer $bestry_uid
 * @property integer $level
 * @property string  $create_time
 * @property integer $is_try
 * @property integer $is_reply
 * @property integer $reply_id
 * @property integer $is_show
 * @property integer $status
 * @property integer $flag
 */
class CommentsRelation extends \yii\db\ActiveRecord
{
    public static $LEVEL = [''=>'请选择', '1'=>'1星', '2'=>'2星', '3'=>'3星', '4'=>'4星', '5'=>'5星'];
    public static $STATUS_A = [/*''=>'请选择', '-1'=>'待审核',*/ '0'=>'通过', '1'=>'精华'/*, '2'=>'未通过'*/];
    public static $STATUS = [''=>'请选择',  '2'=>'不通过', '1'=>'精华'];
    public static $IS_TRY = [''=>'请选择','0'=>'购买', '1'=>'试用'];
    public static $IS_SHOW = [''=>'请选择', '0'=>'不展示', '1'=>'展示'];
    public static $IS_reply = ['0'=>'无', '1'=>'有'];
    public static $FLAG = [''=>'请选择', '0'=>'用户评论', '1'=>'后台评论'];
    public $goods_name;
    public $start_time;
    public $end_time;


    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'd_try.comments_relation';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['comment_id', 'order_id', 'goods_id', 'product_id', 'bestry_uid', 'level', 'is_try', 'is_reply', 'reply_id', 'is_show', 'status', 'flag'], 'integer'],
            [['bestry_uid', 'level', 'create_time', 'is_show', 'status'], 'required'],
            [['create_time','start_time','end_time'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'comment_id' => '评论ID',
            'order_id' => '订单ID',
            'goods_id' => '商品ID',
            'product_id' => '产品ID',
            'bestry_uid' => '用户Uid',
            'level' => '评价星级',
            'create_time' => '评论时间',
            'is_try' => '类型',
            'is_reply' => '有无回复',
            'reply_id' => '回复ID',
            'is_show' => '是否展示',
            'status' => '状态',
            'goods_name'=>'商品名称',
            'start_time'=>'开始时间',
            'end_time'=>'结束时间',
            'flag'  => '是否是后台评论'
        ];
    }

    /**
     * @inheritdoc
     * @return \services\models\CommentsRelationQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \services\models\CommentsRelationQuery(get_called_class());
    }

    public function getComments(){
        return $this->hasOne(Comments::className(), ['comment_id'=>'comment_id']);
    }

    public function getComments_reply(){
        return $this->hasOne(CommentsReply::className(), ['comment_id'=>'comment_id']);
    }

    public function getGoods_detail(){
        return $this->hasOne(GoodsDetail::className(), ['goods_id'=>'goods_id']);
    }

}
